package com.utooo.controller;


import com.utooo.constant.ResultCodeConstant;
import com.utooo.pojo.dto.common.CreateGroup;
import com.utooo.pojo.dto.common.RestResult;
import com.utooo.pojo.dto.supplier.deliveryplan.DeliveryPlanUpdateDto;
import com.utooo.pojo.dto.supplier.execution.PurchasePushDto;
import com.utooo.pojo.dto.supplier.execution.PurchaseUpdateDto;
import com.utooo.service.supplier.PurchaseExecutionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: 采购执行相关接口
 * @Author SJD
 * @Date: 2025/4/22 14:06
 * @Copyright: 南京优通信息科技股份有限公司
 */
@Tag(name = "供应商-采购执行相关接口")
@RequestMapping("/supplier/purchaseexecution")
@RestController
@RequiredArgsConstructor
public class PurchaseExecutionController {

    private final PurchaseExecutionService purchaseExecutionServiceImpl;

    @RequestMapping(value = "/pushPurchase", method = RequestMethod.POST)
    @Operation(summary = "采购方推送采购订单到供应商门户")
    @ResponseBody
    public RestResult<Boolean> pushPurchase(@RequestBody @Validated(CreateGroup.class) PurchasePushDto purchaseExecutionDto) {
        Boolean result = purchaseExecutionServiceImpl.pushPurchase(purchaseExecutionDto);
        return new RestResult<>(ResultCodeConstant.CODE_200, ResultCodeConstant.CODE_200_MSG, result);
    }

    @RequestMapping(value = "/pushTransactionPrice", method = RequestMethod.POST)
    @Operation(summary = "采购方推送采购成交价到历史价格")
    @ResponseBody
    public RestResult<Boolean> pushTransactionPrice(@RequestBody @Validated(CreateGroup.class) PurchasePushDto purchaseExecutionDto) {
        Boolean result = purchaseExecutionServiceImpl.pushTransactionPrice(purchaseExecutionDto);
        return new RestResult<>(ResultCodeConstant.CODE_200, ResultCodeConstant.CODE_200_MSG, result);
    }

    @RequestMapping(value = "/updatePurchase", method = RequestMethod.POST)
    @Operation(summary = "供应商确认采购订单")
    @ResponseBody
    public RestResult<Boolean> updatePurchase(@RequestBody @Validated(CreateGroup.class) PurchaseUpdateDto purchaseUpdateDto) {
        Boolean result = purchaseExecutionServiceImpl.updatePurchase(purchaseUpdateDto);
        return new RestResult<>(ResultCodeConstant.CODE_200, ResultCodeConstant.CODE_200_MSG, result);
    }

    @RequestMapping(value = "/pushDeliveryPlan", method = RequestMethod.POST)
    @Operation(summary = "供应商提交交货计划")
    @ResponseBody
    public RestResult<Boolean> pushDeliveryPlan(@RequestBody @Validated(CreateGroup.class) DeliveryPlanUpdateDto deliveryPlanUpdateDto) {
        Boolean result = purchaseExecutionServiceImpl.pushDeliveryPlan(deliveryPlanUpdateDto);
        return new RestResult<>(ResultCodeConstant.CODE_200, ResultCodeConstant.CODE_200_MSG, result);
    }
    @RequestMapping(value = "/auditDeliveryPlan", method = RequestMethod.POST)
    @Operation(summary = "采购方审核交货计划")
    @ResponseBody
    public RestResult<Boolean> auditDeliveryPlan(@RequestBody @Validated(CreateGroup.class) DeliveryPlanUpdateDto deliveryPlanUpdateDto) {
        Boolean result = purchaseExecutionServiceImpl.auditDeliveryPlan(deliveryPlanUpdateDto);
        return new RestResult<>(ResultCodeConstant.CODE_200, ResultCodeConstant.CODE_200_MSG, result);
    }


}
